package com.dkm.orproject.dkmoa.action;

import com.dkm.orproject.dkmoa.domain.OaMessage;
import com.dkm.orproject.dkmoa.domain.OaPersonnel;
import com.dkm.orproject.dkmoa.service.OaMessageService;
import com.dkm.orproject.utils.jwt.login.UserLoginToken;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName : OaMessageAction  //类名
 * @Description : 流程通知Action  //描述
 * @Author : 易嵘  //作者
 * @Date: 2020-09-16 10:36  //时间
 */
@RestController
@RequestMapping("OaMessageAction")
public class OaMessageAction {

    /**
     * 流程通知接口
     */
    @Resource
    OaMessageService messageService;

    /**
     *
     * @return 通知结果
     */
    @UserLoginToken
    @GetMapping("findAll")
    public Map<String,Object> findAll(HttpServletRequest request){
        Map<String,Object> map=new HashMap<>(16);
        OaPersonnel personnel= (OaPersonnel) request.getSession().getAttribute("user");
        if(ObjectUtils.isEmpty(personnel)){
            return map;
        }
        map.put("Backlog",messageService.findAllBacklog(personnel));
        map.put("ToBeRead",messageService.findAllToBeRead(personnel));
        map.put("HaveDone",messageService.findAllHaveDone(personnel));
        return map;
    }

}
